Sheets [A]
Memory limit: 32 MB
Little John has just started to learn about the addition operation at school.
His mother came up with a new game which can help John with learning.
At the beginning of the game, John's mother writes all integer numbers in the range from to
on separate sheets of paper. She then forms a row of sheets,
keeping the order of numbers on sheets unchanged (from to ).
John's task is to perform a given action a number of times. The action consists of:
picking up first sheets from the row, summing up the numbers written on these
sheets, tearing and throwing away those sheets and writing the obtained sum on a new sheet and locating it at the end of the row.
If at some point of the game there are less than sheets in the row, John doesn't worry about it and he adds the values of all
the remaining sheets.
John really enjoys the new game. He keeps asking his mother to check whether he has made any mistake while calculating the consecutive sums.
What is more, John plays this game really well so he tries his chances for bigger and bigger values of and .
John's mother can't keep up with checking the results obtained by John, so she asked you to write a program that will
validate the results for her.
Task
Write a program which:
- reads numbers , and from the standard input,
- calculates what the sum should be written by John in the -th move,
- writes the result to the standard output.
Input
In the first line of the standard input there is one integer () which denotes the number of queries to proceed.
Each query is located in a separate line and is represented by three integers , and
(), separated by single spaces. Such a query asks for a number which John should write on the sheet
in the -th move in the game represented by parameters and .
Output
Output should consist of lines. -th line should contain one integer - the answer to the -th query.
Example
For the input data:
6
6 2 1
6 2 2
6 2 3
6 2 4
6 2 5
6 2 6
the correct result is:
3
7
11
10
21
21
Task author: Jakub Radoszewski.